package com.itheima.redbaby.engine.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.itheima.redbaby.ContantValue;
import com.itheima.redbaby.bean.BrandValue;
import com.itheima.redbaby.bean.Product;
import com.itheima.redbaby.bean.Value;
import com.itheima.redbaby.engine.BaseEngine;
import com.itheima.redbaby.engine.BrandEngine;

public class BrandEngineImpl extends BaseEngine implements BrandEngine {

	@Override
	public List<Value> getBrandInfo() {

		// 获取json 对象
		JSONObject json = getJson(TYPE_GET, ContantValue.REDBOY_BRAND, null);

		List<Value> brandList = JSONObject.parseArray(json.getString("brand"),
				Value.class);
		
		for (int i = 0; i < brandList.size(); i++) {
			System.out.println(  brandList.get(i));
		}

		return brandList;
	}

	public List<String> BrandID() {
		List<String> brandID = new ArrayList<String>();

		// 获取json 对象
		JSONObject json = getJson(TYPE_GET, ContantValue.REDBOY_BRAND, null);
		List<Value> brandList = JSONObject.parseArray(json.getString("brand"),
				Value.class);

		for (Value value : brandList) {
			List<BrandValue> values = value.getValue();
			for (BrandValue brandValue : values) {
				String id = brandValue.getId();
				brandID.add(id);
			}
		}
		return brandID;

	}
}
